<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
 * PHP version 5
 *
 * This source file is subject to version 2.1 of the GNU Lesser General Public
 * License, that is bundled with this package in the file COPYING, available
 * through the world wide web at the following URI:
 * http://www.gnu.org/copyleft/lesser.html.
 *
 * @package    ZNF
 * @subpackage Action
 * @author     Alessandro Rossini <http://www.alessandrorossini.org>
 * @author     Graziano Liberati <http://www.liberati.org>
 * @copyright  2004-2007 The ZNF Development Team
 * @license    LGPL License 2.1 <http://www.gnu.org/copyleft/lesser.html>
 * @version    SVN $Id: ActionErrors.php 43 2007-06-26 23:36:35Z aronnax $
 * @since      Release 0.5.0
 * @link       http://www.zeronotice.org
 */

/**
 * <i>ZNF_Action_ActionErrors</i> class encapsulates the error messages being reported by the <i>ZNF_Action_ActionForm->validate()</i> method.
 *
 * Each individual error is described by a key and a relative message.
 *
 * @access     public
 * @package    ZNF
 * @subpackage Action
 * @author     Alessandro Rossini <http://www.alessandrorossini.org>
 * @author     Graziano Liberati <http://www.liberati.org>
 * @copyright  2004-2007 The ZNF Development Team
 * @license    LGPL License 2.1 <http://www.gnu.org/copyleft/lesser.html>
 * @version    SVN $Id: ActionErrors.php 43 2007-06-26 23:36:35Z aronnax $
 * @since      Release 0.5.0
 * @link       http://www.zeronotice.org
 */
class ZNF_Action_ActionErrors
{

    /**
     * Array where the set of errors are stored.
     *
     * @access protected
     * @var array $_errors
     */
    protected $_errors = array();

    /**
     * Constructs a new <i>ZNF_Action_ActionErrors</i> object.
     *
     * @access public
     */
    public function __construct()
    {
    }

    /**
     * Adds an error message to the set of errors.
     *
     * @access public
     * @param int $key
     * @param string $value
     */
    public function addError($key, $value)
    {
        if ($key) {
            $this->_errors[$key] = $value;
        }
    }

    /**
     * Returns the set of errors.
     *
     * @access public
     * @return array
     */
    public function getErrors()
    {
        return $this->_errors;
    }

    /**
     * Returns number of errors.
     *
     * @access public
     * @return int
     */
    public function getNumErrors()
    {
        return count($this->_errors);
    }

    /**
     * Returns an error by the key.
     *
     * @access public
     * @param int $key
     * @return string
     */
    public function findError($key)
    {
        if (array_key_exists($key, $this->_errors)) {
            return $this->_errors[$key];
        } else {
            return null;
        }
    }

    /**
     * Destroys the <i>ZNF_Action_ActionErrors</i> object.
     *
     * @access public
     */
    public function __destruct()
    {
    }

}

/**
 * <i>ZNF_Action_ActionErrorsException</i> is the exception type for the <i>ZNF_Action_ActionErrors</i> class.
 *
 * <i>ZNF_Action_ActionErrorsException</i> extends the <i>Exception</i> class of PHP5.
 *
 * @access     public
 * @package    ZNF
 * @subpackage Action
 * @author     Alessandro Rossini <http://www.alessandrorossini.org>
 * @author     Graziano Liberati <http://www.liberati.org>
 * @copyright  2004-2007 The ZNF Development Team
 * @license    LGPL License 2.1 <http://www.gnu.org/copyleft/lesser.html>
 * @version    SVN $Id: ActionErrors.php 43 2007-06-26 23:36:35Z aronnax $
 * @since      Release 0.5.0
 * @link       http://www.zeronotice.org
 */
class ZNF_Action_ActionErrorsException extends Exception
{
}

?>
